//package nancal.mp
//
//import com.alibaba.cloud.nacos.NacosConfigProperties
//import com.alibaba.cloud.nacos.NacosDiscoveryProperties
//import nbcp.comm.AsInt
//import nbcp.base.extend.*
//import java.io.*
//import nbcp.component.SnowFlake
//import nbcp.comm.AsLocalDateTime
//import nbcp.myoql.db.mongo.delete
//import nancal.mp.db.mongo.mor
//import nbcp.base.mvc.service.SnowFlakeRedisService
//import java.io.*

//import nbcp.base.utils.*
//import org.slf4j.LoggerFactory
//import org.springframework.beans.factory.annotation.Autowired
//import org.springframework.boot.context.event.ApplicationPreparedEvent
//import org.springframework.boot.context.event.ApplicationReadyEvent
//import org.springframework.cloud.client.discovery.event.InstanceRegisteredEvent
//import org.springframework.context.annotation.Bean
//import org.springframework.context.annotation.Configuration
//import org.springframework.context.event.EventListener
//import org.springframework.core.convert.converter.Converter
//import org.springframework.stereotype.Component
//import java.time.LocalTime
//
//@Configuration
//class SnowFlakeMachineIdService {
//
//    companion object {
//        private val logger = LoggerFactory.getLogger(this::class.java.declaringClass)
//    }
//
//    @Autowired
//    lateinit var nacosService: SnowFlakeRedisService;
//
//    fun setSnowFlakeMachineId(ip: String, port: Int) {
//        val machineId = nacosService.getSnowFlakeMachineId(
//            SpringUtil.context.environment.getProperty("spring.profiles.active"),
//            SpringUtil.context.environment.getProperty("spring.application.name"),
//            ip,
//            port
//        )
//
//        SpringUtil.getBean<SnowFlake>().machineId = machineId
//        logger.info("机器Id：${machineId}")
//    }
//
//    @EventListener
//    fun afterPropertiesSet(event: InstanceRegisteredEvent<NacosDiscoveryProperties>) {
//        var config = event.config;
//        this.setSnowFlakeMachineId(config.ip, config.port)
//    }
//
//}
//
//@Component
//class StringToLocalTimeConverter : Converter<String, LocalTime> {
//    /**
//     * @see org.springframework.core.convert.converter.Converter.convert
//     */
//    override fun convert(source: String): LocalTime? {
//        var v = source.AsLocalDateTime()
//        if (v == null) return null;
//        return v.toLocalTime()
//    }
//}